package pe.com.tma.dao.jpa;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.Query;

import pe.com.tma.dao.InstrumentoDAO;
import pe.com.tma.model.Instrumento;
import pe.com.tma.model.Orden;
import pe.com.tma.util.BusquedaGrl;

public class JPAInstrumentoDAO extends GenericDAOJpa<Long, Instrumento> implements InstrumentoDAO {

	private EntityManager em = getEntityManager();

	@Override
	public List<Instrumento> obtenerInstrumentos(BusquedaGrl busc) {
		// TODO Auto-generated method stub
		try {
			Query q = em.createQuery("SELECT c FROM Instrumento c Where c.idInstrumento LIKE ?1 ");
			q.setParameter(1, busc.getIdStr()+"%");
			//q.setParameter(1, 1);
			return q.getResultList();
			
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
	
}
